﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OracleClient;

public partial class sanpham : System.Web.UI.Page
{
    

    private void load()
    {
       
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        DataConnection.str = @"Data Source=xe;User ID=ODER;Password=12345";
        if (!Page.IsPostBack)
        {
            load();
            BindData();
        }
    }
    //public string xuatchuoi()
    //{
    //    string chuoi;
    //    if (Request.QueryString["MaSach"] == null)
    //    {
    //        chuoi = @"select * from Sach";
    //    }
    //    else
    //    {
    //        string masach = Convert.ToString(Request.QueryString["MaSach"]);
    //        chuoi = "Select * from Sach where masach=" + masach;
    //    }

    //    if (Request.QueryString["TacGia"] != null)
    //    {
    //        string tacgia = Convert.ToString(Request.QueryString["TacGia"]);
    //        chuoi = "Select * from Sach where tacgia=" + "'" + tacgia + "'";
    //    }
    //    if (Request.QueryString["DonGia"] != null)
    //    {
    //        string dongia = Convert.ToString(Request.QueryString["DonGia"]);
    //        chuoi = "Select * from Sach where " + dongia;
    //    }
    //    return chuoi;
    //}
    public DataSet getSP()
    {

        
        DataSet ds = new DataSet();
        ds = DataConnection.GetDatasetByStoreProcedureName("NGOCTRAN.sp_getAllsach");
        return ds;

    }
    public void BindData()
    {
        try
        {
            if (getSP().Tables[0].Rows.Count > 0)
            {
                MultiView1.ActiveViewIndex = 0;
                clp1.PageSize = 12;
                clp1.DataSource = getSP().Tables[0].DefaultView;
                clp1.BindToControl = dlsanpham;
                dlsanpham.DataSource = clp1.DataSourcePaged;
                dlsanpham.DataBind();
            }
            else
            {
                MultiView1.ActiveViewIndex = 1;
                lbkhongcosanpham.Text = "Sản Phẩm Bạn Tìm Kiếm Không Có Trong Cơ Sở Dữ Liệu";
            }
        }
        catch (OracleException ex)
        { }
    }
    

    protected void MultiView1_ActiveViewChanged(object sender, EventArgs e)
    {

    }
    protected void dlsanpham_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}